package cjh;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.Timer;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.Dimension;
import javax.swing.JTabbedPane;
import java.awt.FlowLayout;
import javax.swing.JScrollPane;

// 관리자 메인 페이지
public class AdminPage_Main extends JFrame {

	private static AdminPage_Main frame;
	private JPanel main_panel;

	// 메인 - 런 메인페이지 불러오기

	public static void main(String[] args) {

		EventQueue.invokeLater(new Runnable() {

			@Override
			public void run() {

				frame = new AdminPage_Main();
				frame.setVisible(true);

			}
		});

	}

	public AdminPage_Main() {

		setBounds(300, 300, 1024, 768);
		// 상단 제어
		JPanel top_panel = new JPanel();

		getContentPane().add(top_panel, BorderLayout.NORTH);
		top_panel.setPreferredSize(new Dimension(1024, 100));
		top_panel.setBounds(100, 100, 1024, 400);
		top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.Y_AXIS));

		// 상단 - 메뉴 패널
		JPanel menubar = new JPanel();
		makeMenuButton(menubar);
		top_panel.add(menubar);

		// 툴바패널
		JPanel toolbar = new JPanel();
		makeToolPanel(toolbar);

		top_panel.add(toolbar);

		// 목록 제어

		// 학과정보
		/*
		 * JPanel info_panel = new Info_Panel(); info_panel.setPreferredSize(new
		 * Dimension(200, 10)); info_panel.setLayout( new BoxLayout( info_panel,
		 * BoxLayout.Y_AXIS ) ); getContentPane().add(info_panel,
		 * BorderLayout.WEST);
		 */

		// 본문패널. 탭패널 제어 가능할까?-불가능
		// 검색한 방식 -하나씩뜨게 만들기위에 패널창처럼 - 고려해볼 가치 있음

		// 기본창
		main_panel = new Admin_Main_BasicPanel();

		// 관리자등록 정보창
		//main_panel = new Admin_Setting();
		// 캘린더 확인

		// JPanel main_panel = new JPanel();

		// 학사정보

		// 교수정보창
		// JPanel main_panel = new Main_ProfesserInfo();
		getContentPane().add(main_panel, BorderLayout.CENTER);

		// 학사일정

		// 학생정보 - 제복이 파일 활용

		// 건물관리

		// main_panel =

		setVisible(true);
	}

	// 이벤트 세팅 메서드
	/*
	 * private void setEvent( int action ) {
	 * 
	 * 
	 * switch( action ){ case 1 : main_panel ; break;
	 * 
	 * 
	 * 
	 * 
	 * }; }
	 */

	private void toolPanel() {

		JPanel top = new JPanel();
		makeToolPanel(top);

	}

	private void makeToolPanel(JPanel p) {

		JButton cgStu_btn = new JButton("툴바");
		p.add(cgStu_btn);
		JButton cgEmpo_btn = new JButton("확인");
		p.add(cgEmpo_btn);
		JButton btnAdmin = new JButton("창");
		p.add(btnAdmin);

	}

	private void makeMenuButton(JPanel p) {

		JButton home = new JButton("HOME");
		home.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getContentPane().remove(main_panel); // 실시간 업데이트를해 주어야함
				main_panel = new Admin_Main_BasicPanel();

				getContentPane().add(main_panel, BorderLayout.CENTER);
				setVisible(true);
			}
		});
			
		p.add(home);
		
		
		JButton depart = new JButton("학사정보 관리");
		depart.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getContentPane().remove(main_panel); // 실시간 업데이트를해 주어야함
				main_panel = new Admin_Depart_Main();

				getContentPane().add(main_panel, BorderLayout.CENTER);
				setVisible(true);
				
			}

		});

		/*
		 * depart.addMouseListener( new MouseListener() { `
		 * 
		 * @Override public void mouseClicked(MouseEvent e) { if (
		 * e.getClickCount() == 1 ){ getContentPane().remove(main_panel);
		 * 
		 * }
		 * 
		 * }
		 * 
		 * @Override public void mousePressed(MouseEvent e) { // TODO
		 * Auto-generated method stub
		 * 
		 * }
		 * 
		 * @Override public void mouseReleased(MouseEvent e) { // TODO
		 * Auto-generated method stub
		 * 
		 * }
		 * 
		 * @Override public void mouseEntered(MouseEvent e) { // TODO
		 * Auto-generated method stub
		 * 
		 * }
		 * 
		 * @Override public void mouseExited(MouseEvent e) { // TODO
		 * Auto-generated method stub
		 * 
		 * } } );
		 * 
		 * 
		 * // 기본틀
		 * 
		 * 
		 * // 에드써서 기존 새로운 레이아웃 추가 depart_main = new Admin_Depart_Main();
		 * getContentPane().add( depart_main, BorderLayout.CENTER);
		 */

		p.add(depart);

		JButton prof = new JButton("교직원 관리");
		prof.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getContentPane().remove(main_panel); // 실시간 업데이트를해 주어야함
				main_panel = new Admin_Prof_Main();

				getContentPane().add(main_panel, BorderLayout.CENTER);
				setVisible(true);
				
			}

		});
		p.add(prof);
		JButton admin = new JButton("Admin");
		admin.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getContentPane().remove(main_panel); // 실시간 업데이트를해 주어야함
				main_panel = new Admin_Setting();

				getContentPane().add(main_panel, BorderLayout.CENTER);
				setVisible(true);
				
			}

		});
		p.add(admin);

	}

} // class

/*
 * 
 * class top_ToolPanel extends AdminPage_Main {
 * 
 * 
 * 
 * private void toolPanel(){
 * 
 * JPanel top = new JPanel(); // makeToolPanel( top );
 * 
 * }
 * 
 * private void makeToolButton( JPanel p ){
 * 
 * JButton cgStu_btn = new JButton("툴바"); p.add( cgStu_btn ); JButton cgEmpo_btn
 * = new JButton("확인"); p.add( cgEmpo_btn ); JButton btnAdmin = new
 * JButton("창"); p.add( btnAdmin );
 * 
 * 
 * }
 * 
 * 
 * 
 * 
 * } // classToolPanel
 */